package com.dun.mvc.dao;

import java.util.List;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.stereotype.Component;

import com.dun.mvc.vo.User;

@Component
public class UserDaoImpl {

	private HibernateTemplate template;
	private Session session;

	@Autowired
	public void setSessionFactory(SessionFactory sessionFactory) {
		this.template = new HibernateTemplate(sessionFactory);
		this.session = this.template.getSessionFactory().openSession();
	}

	public List<User> getUsers() {
		List<User> userList = session.createCriteria(User.class).list();
		return userList;
	}
}
